//package com.example.springboot.mapping;
//
//import org.springframework.core.annotation.AnnotationUtils;
//import org.springframework.web.servlet.mvc.condition.RequestCondition;
//import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
//
//import java.lang.reflect.Method;
//import java.util.Arrays;
//
///**
// * 自定义请求mapping映射
// *
// * @author by Mr. Li 2021/1/30 15:53
// */
//public class CustomRequestMappingHandlerMapping extends RequestMappingHandlerMapping {
//    @Override
//    protected RequestCondition<?> getCustomMethodCondition(Method method) {
//        // 读取方法上 是否存在ApiVersion 注解
//        return getApiVersionAnnotation(method);
//    }
//
//    /**
//     * 容器在加载会加载所有请求映射的信息{@link RequestMappingHandlerMapping#createRequestMappingInfo(java.lang.reflect.AnnotatedElement)}
//     * 机会调用该方法，获取所有的请求
//     * @param method
//     * @return
//     */
//    private RequestCondition<?> getApiVersionAnnotation(Method method) {
//        final ApiVersion annotation = AnnotationUtils.findAnnotation(method, ApiVersion.class);
//        return annotation != null ? new ApiVersionCondition(Arrays.stream(annotation.version()).toArray(String[]::new)) : null;
//    }
//}
